package com.car.service.impl;

<<<<<<< HEAD
import java.util.List;

import com.car.dao.impl.CarDaoImpl;
import com.car.dao.impl.Car_insuDaoImpl;
import com.car.dao.impl.CompanyDaoImpl;
import com.car.entity.Car;
import com.car.entity.Customer;
import com.car.entity.Driver;
import com.car.entity.User;
import com.car.service.UserService;

public class UserServiceImpl implements UserService{
	
	private Car_insuDaoImpl car_insuDao = new Car_insuDaoImpl();
	private CarDaoImpl carDao = new CarDaoImpl();
	private CompanyDaoImpl companyDao = new CompanyDaoImpl();
	

	@Override
	public boolean regist(User user, Customer customer) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean login(User user) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean modifyUser(User user, Customer customer) {
		// TODO Auto-generated method stub
		return false;
	}

=======
import java.sql.SQLException;
import java.util.List;

import com.car.dao.impl.CarDaoImpl;
import com.car.dao.impl.Car_insuDaoImpl;
import com.car.dao.impl.CompanyDaoImpl;
import com.car.dao.impl.CustomerDaoImpl;
import com.car.dao.impl.DetailsDaoImpl;
import com.car.dao.impl.DriverDaoImpl;
import com.car.dao.impl.OrdersDaoImpl;
import com.car.dao.impl.UserDaoImpl;
import com.car.entity.Car;
import com.car.entity.Customer;
import com.car.entity.Driver;
import com.car.entity.User;
import com.car.service.UserService;

public class UserServiceImpl implements UserService{
	
	private Car_insuDaoImpl car_insuDao = new Car_insuDaoImpl();
	private CarDaoImpl carDao = new CarDaoImpl();
	private CompanyDaoImpl companyDao = new CompanyDaoImpl();
	private CustomerDaoImpl cutomerDaoImpl = new CustomerDaoImpl();
	private DetailsDaoImpl detailsDaoImpl;
	private DriverDaoImpl driverDaoImpl;
	private OrdersDaoImpl ordersDaoImpl;
	private UserDaoImpl userDaoImpl;
	
	{
		detailsDaoImpl = new DetailsDaoImpl();
		driverDaoImpl = new DriverDaoImpl();
		ordersDaoImpl = new OrdersDaoImpl();
		userDaoImpl = new UserDaoImpl();
	}
	

	@Override
	public boolean regist(User user, Customer customer) throws SQLException {
		boolean isExist = queryUserIsExist(user.getUsername());
		// 如果为true,用户名存在
		if (isExist) {
			return false;
		}
		int insert = userDaoImpl.insert(user);
		int insert2 = cutomerDaoImpl.insert(customer);
		if (insert != 1 || insert2 != 1) {
			userDaoImpl.delete(user.getU_id());
			cutomerDaoImpl.delete(cutomerDaoImpl.delete(customer.getKno()));
			return false;
		}
		return true;
	}
	
	/**
	 * 查询用户名是否存在
	 * true:存在
	 * false:不存在
	 * @param username
	 * @return
	 * @throws SQLException
	 */
	public boolean queryUserIsExist(String username) throws SQLException {
		User user = userDaoImpl.queryByUsername(username);
		if (user == null) {
			return false;
		}else {
			return true;
		}
	}

	@Override
	public boolean login(User user) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean modifyUser(User user, Customer customer) {
		// TODO Auto-generated method stub
		return false;
	}

	
>>>>>>> branch 'master' of https://gitee.com/kangdg/car.git
	@Override
	public List<Car> showCar() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Driver> showDriver() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Car rentCar(int carid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Driver rentDriver(int driverid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Car returnCar(int carid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Driver returnDriver(int driverid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String showOrder(int id) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean delOrder() {
		// TODO Auto-generated method stub
		return false;
	}

}
